<?php echo $header; ?>
<?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>
<div class="box">
  <div class="left"></div>
  <div class="right"></div>
  <div class="heading">
    <h1 style="background-image: url('view/image/pie.png');"><?php echo $heading_title; ?></h1>
    <div class="buttons"><a onclick="$('#form').submit();" class="button"><span><?php echo $button_save; ?></span></a><a onclick="location='<?php echo $cancel; ?>';" class="button"><span><?php echo $button_cancel; ?></span></a></div>
  </div>
  <div class="content">
    <div id="tabs" class="htabs"><a tab="#tab_general"><?php echo $tab_general; ?></a><a tab="#tab_data"><?php echo $tab_data; ?></a></div>
    <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
      <div id="tab_general">
        
          <table class="form">
            <tr>
              <tbody id="image_row" id="images">
	            <tr>
	              <td><?php echo $column_logo; ?></td>
	              <td class="left"><input type="hidden" name="image" value="<?php echo $image; ?>" id="image"  />
	                <?php echo $URLimage; ?></td>	              
	            </tr>
	          </tbody>
              <tr>
              	<td valign="top" class="left"><?php echo $text_size;?></td>
              	<td valign="top"><?php echo $text_logo_width;?><input type="text" name="logo_width" value="<?php echo $logo_width;?>" size="3">x <?php echo $text_logo_height;?> <input type="text" name="logo_height" value="<?php echo $logo_height;?>" size="3"></td>
              </tr>            
              <tr>
			    <td valign="top" class="left"><?php echo $text_site_url;?></td>
			    <td valign="top"><input type="text" name="site_url" value="<?php echo $site_url;?>" size="60"></td>
			  </tr>
              <tr>
              	<td valign="top" class="left"><?php echo $text_start_date;?></td>
              	<td valign="top"><input type="text" name="start_date" value="<?php echo $start_date; ?>" size="12" class="date" /></td>
              </tr>
              <tr>
              	<td valign="top" class="left"><?php echo $text_end_date;?></td>
              	<td valign="top"><input type="text" name="end_date" value="<?php echo $end_date; ?>" size="12" class="date" /></td>
              </tr>
             
			  <tr>
            <td width="25%"><?php echo $entry_status; ?></td>
            <td><select name="status">
              <?php if ($status) { ?>
              <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
              <option value="0"><?php echo $text_disabled; ?></option>
              <?php } else { ?>
              <option value="1"><?php echo $text_enabled; ?></option>
              <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
              <?php } ?>
            </select></td>
          </tr>
          <tr>
            <td><?php echo $entry_store; ?></td>
            <td><div class="scrollbox">
                <?php $class = 'even'; ?>
                <div class="<?php echo $class; ?>">
                  <?php if (in_array(0, $logo_store)) { ?>
                  <input type="checkbox" name="logo_store[]" value="0" checked="checked" />
                  <?php echo $text_default; ?>
                  <?php } else { ?>
                  <input type="checkbox" name="logo_store[]" value="0" />
                  <?php echo $text_default; ?>
                  <?php } ?>
                </div>
                <?php foreach ($stores as $store) { ?>
                <?php $class = ($class == 'even' ? 'odd' : 'even'); ?>
                <div class="<?php echo $class; ?>">
                  <?php if (in_array($store['store_id'], $logo_store)) { ?>
                  <input type="checkbox" name="logo_store[]" value="<?php echo $store['store_id']; ?>" checked="checked" />
                  <?php echo $store['name']; ?>
                  <?php } else { ?>
                  <input type="checkbox" name="logo_store[]" value="<?php echo $store['store_id']; ?>" />
                  <?php echo $store['name']; ?>
                  <?php } ?>
                </div>
                <?php } ?>
              </div></td>
          </tr>
          <tr>
            <td><?php echo $entry_active; ?></td>
            <td><?php if (isset($new_logo)) { echo $text_new_logo; ?>
              <input type="hidden" name="active" value="0" />
              <?php } else { ?>
              <select name="active">
              <?php if ($active) { ?>
              <option value="1" selected="selected"><?php echo $text_active; ?></option>
              <option value="0"><?php echo $text_inactive; ?></option>
              <?php } else { ?>
              <option value="1"><?php echo $text_active; ?></option>
              <option value="0" selected="selected"><?php echo $text_inactive; ?></option>
              <?php } ?>
              </select>
              <?php foreach ($languages as $language) { ?>
                <?php if (isset($error_active_logo[$language['language_id']])) { ?>
                <span class="error"><?php echo $error_active_logo[$language['language_id']]; ?></span>
                <?php } ?>
              <?php } ?>
            <?php } ?></td>
          </tr>
          </table>
        </div>
        
      
      <div id="tab_data">
      	<div id="languages" class="htabs">
          <?php foreach ($languages as $language) { ?>
          <a tab="#language<?php echo $language['language_id']; ?>"><img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /> <?php echo $language['name']; ?></a>
          <?php } ?>
        </div>
        <?php foreach ($languages as $language) { ?>
        <div id="language<?php echo $language['language_id']; ?>">
        <table class="form">
            <tr>
			    <td valign="top" class="left"><?php echo $text_website_name;?></td>
			    <td valign="top"><input type="text" name="site_name[<?php echo $language['language_id']; ?>][name]" value="<?php echo isset($site_name[$language['language_id']]) ? $site_name[$language['language_id']]['name'] : ''; ?>" size="60">
			 	<?php if (isset($error_name[$language['language_id']])) { ?>
                <span class="error"><?php echo $error_name[$language['language_id']]; ?></span>
                <?php } ?></td>
			 </tr>
        </table>
        
      </div> 
      <?php } ?>     
    </form>
  </div>
</div>
<script type="text/javascript" src="view/javascript/ckeditor/ckeditor.js"></script>
<script type="text/javascript"><!--
<?php foreach ($languages as $language) { ?>
CKEDITOR.replace('description<?php echo $language['language_id']; ?>', {
	filebrowserBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserImageBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserFlashBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserImageUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserFlashUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>'
});
<?php } ?>
//--></script>
<script type="text/javascript" src="view/javascript/jquery/ui/ui.draggable.js"></script>
<script type="text/javascript" src="view/javascript/jquery/ui/ui.resizable.js"></script>
<script type="text/javascript" src="view/javascript/jquery/ui/ui.dialog.js"></script>
<script type="text/javascript" src="view/javascript/jquery/ui/external/bgiframe/jquery.bgiframe.js"></script>
<script type="text/javascript"><!--
function image_upload(field, preview) {
	$('#dialog').remove();
	
	$('#content').prepend('<div id="dialog" style="padding: 3px 0px 0px 0px;"><iframe src="index.php?route=common/filemanager&token=<?php echo $token; ?>&field=' + encodeURIComponent(field) + '" style="padding:0; margin: 0; display: block; width: 100%; height: 100%;" frameborder="no" scrolling="auto"></iframe></div>');
	
	$('#dialog').dialog({
		title: '<?php echo $text_image_manager; ?>',
		close: function (event, ui) {
			if ($('#' + field).attr('value')) {
				$.ajax({
					url: 'index.php?route=common/filemanager/image2&token=<?php echo $token; ?>',
					type: 'POST',
					data: 'image=' + encodeURIComponent($('#' + field).attr('value')),
					dataType: 'text',
					success: function(data) {
					
						if(data.substr(-4)=='.swf'){
							$('#' + preview).replaceWith('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="200" height="200" id="preview"><param name="movie" value="'+data+'"><param name="quality" value="high"><embed src="'+data+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="200" height="200"></embed></object><div id="change_logo" class="buttons"><span><a onclick="image_upload(\'image\', \'preview\');" class="button">Chọn Logo</a></span></div>');
						}else{	
											
							$('#' + preview).replaceWith('<img src="' + data + '" alt="" id="' + preview + '" class="image" onclick="image_upload(\'' + field + '\', \'' + preview + '\');" />');
						}

					}
				});
			}
		},	
		bgiframe: false,
		width: 700,
		height: 400,
		resizable: false,
		modal: false
	});
	$('#change_logo').remove();
};
//--></script>
<script type="text/javascript"><!--
var image_row = <?php echo $image_row; ?>;

function addImage() {
    html  = '<tbody id="image_row' + image_row + '">';
	html += '<tr>';
	html += '<td class="left"><input type="hidden" name="product_image[' + image_row + ']" value="" id="image' + image_row + '" /><img src="<?php echo $no_image; ?>" alt="" id="preview' + image_row + '" class="image" onclick="image_upload(\'image' + image_row + '\', \'preview' + image_row + '\');" /></td>';
	html += '<td class="left"><a onclick="$(\'#image_row' + image_row  + '\').remove();" class="button"><span><?php echo $button_remove; ?></span></a></td>';
	html += '</tr>';
	html += '</tbody>';
	
	$('#images tfoot').before(html);
	
	image_row++;
}
//--></script>
<script type="text/javascript" src="view/javascript/jquery/ui/ui.datepicker.js"></script>
<script type="text/javascript"><!--
$(document).ready(function() {
	$('.date').datepicker({dateFormat: 'yy-mm-dd'});
});
//--></script>
<script type="text/javascript"><!--
$.tabs('#tabs a'); 
$.tabs('#languages a'); 
//--></script>
<?php echo $footer; ?>
